{extend name="layout"}
{block name="content"}
<section class="Hui-article-box">
    <nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
        <span class="c-gray en">&gt;</span>
        品牌管理
        <span class="c-gray en">&gt;</span>
        编辑<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
             href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a>
    </nav>
    <div class="Hui-article">
        <form class="form form-horizontal" action="{:url('update',['brand_id'=>$info.brand_id])}">
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-1"><span class="c-red">*</span>中文名称</label>
                <div class="formControls col-xs-8 col-sm-2">
                    <input type="text" class="input-text" name="brand_name" value="{$info.brand_name}">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-1">英文名称</label>
                <div class="formControls col-xs-8 col-sm-2">
                    <input type="text" class="input-text" name="brand_letter" value="{$info.brand_letter}">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-1">品牌首字母</label>
                <div class="formControls col-xs-8 col-sm-2">
                    <input type="text" class="input-text" name="brand_first_char" value="{$info.brand_first_char}">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-1">品牌网址</label>
                <div class="formControls col-xs-8 col-sm-2">
                    <input type="text" class="input-text" name="site_url" value="{$info.site_url}">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-1"><span class="c-red">*</span>品牌LOGO</label>
                <div class="formControls col-xs-8 col-sm-4">
                    <button type="button" class="layui-btn" id="logo">上传图片</button>
                    <img class="layui-upload-img brand_logo" src="{$info.brand_logo}" style="width: 100px;">
                    <input type="hidden" class="input-text" id="brand_logo" name="brand_logo"
                           value="{$info.brand_logo}">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-1">品牌专区大图</label>
                <div class="formControls col-xs-8 col-sm-4">
                    <button type="button" class="layui-btn" id="img">上传图片</button>
                    <img class="layui-upload-img index_img" src="{$info.index_img}" style="width: 100px;">
                    <input type="hidden" class="input-text" id="index_img" name="index_img" value="{$info.index_img}">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-1">品牌背景图</label>
                <div class="formControls col-xs-8 col-sm-4">
                    <button type="button" class="layui-btn" id="bg">上传图片</button>
                    <img class="layui-upload-img brand_bg" src="{$info.brand_bg}" style="width: 100px;">
                    <input type="hidden" class="input-text" id="brand_bg" name="brand_bg" value="{$info.brand_bg}">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-1">品牌描述</label>
                <div class="formControls col-xs-8 col-sm-4">
                    <textarea name="brand_desc" class="textarea">{$info.brand_desc|default=''}</textarea>
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-1">排序</label>
                <div class="formControls col-xs-8 col-sm-2">
                    <input type="text" class="input-text" name="sort_order" value="{$info.sort_order|default='50'}">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-1">是否显示</label>
                <div class="formControls col-xs-8 col-sm-4 skin-minimal">
                    <div class="radio-box">
                        <input type="radio" name="is_show" value="1" checked>
                        <label>是</label>
                    </div>
                    <div class="radio-box">
                        <input type="radio" value="0" name="is_show">
                        <label>否</label>
                    </div>
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-1">加入推荐</label>
                <div class="formControls col-xs-8 col-sm-4 skin-minimal">
                    <div class="radio-box">
                        <input type="radio" name="audit_status" value="1" checked>
                        <label>是</label>
                    </div>
                    <div class="radio-box">
                        <input type="radio" value="0" name="audit_status">
                        <label>否</label>
                    </div>
                </div>
            </div>
            <div class="row cl">
                <div class="col-xs-8 col-sm-2 col-xs-offset-4 col-sm-offset-1">
                    <button class="btn btn-primary radius" type="submit"> 提交</button>
                </div>
            </div>
        </form>
    </div>
</section>
{/block}
{block name="js"}
<link rel="stylesheet" type="text/css" href="/static/admin/layui/css/layui.css">
<script type="text/javascript" src="/static/admin/layui/layui.all.js"></script>
<script>
    layui.use('upload', function () {
        var $ = layui.jquery, upload = layui.upload;
        //普通图片上传
        var uploadInst = upload.render({
            elem: '#logo',
            url: "{:url('admin/Upload/upload')}",
            before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('.brand_logo').attr('src', result); //图片链接（base64）
                });
            }
            , done: function (res) {
                //如果上传失败
                if (res.success == 0) {
                    return layer.msg('上传失败');
                }
                //上传成功
                $('#brand_logo').val(res.url); //图片链接（base64）
                layer.msg('上传成功');
            }
            , error: function () {
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function () {
                    uploadInst.upload();
                });
            }
        });
        var uploadInst = upload.render({
            elem: '#img',
            url: "{:url('admin/Upload/upload')}",
            before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('.index_img').attr('src', result); //图片链接（base64）
                });
            }
            , done: function (res) {
                //如果上传失败
                if (res.success == 0) {
                    return layer.msg('上传失败');
                }
                //上传成功
                $('#index_img').val(res.url); //图片链接（base64）
                layer.msg('上传成功');
            }
            , error: function () {
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function () {
                    uploadInst.upload();
                });
            }
        });
        var uploadInst = upload.render({
            elem: '#bg',
            url: "{:url('admin/Upload/upload')}",
            before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('.brand_bg').attr('src', result); //图片链接（base64）
                });
            }
            , done: function (res) {
                //如果上传失败
                if (res.success == 0) {
                    return layer.msg('上传失败');
                }
                //上传成功
                $('#brand_bg').val(res.url); //图片链接（base64）
                layer.msg('上传成功');
            }
            , error: function () {
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function () {
                    uploadInst.upload();
                });
            }
        });
    });
</script>
{/block}